from ChessBoard import *
from getLastMove import getLastMove
import time

#plays a game of chess, which it reads from a file.

chessboard = ChessBoard()
chessboard.resetBoard()

f = open('moves.txt', 'r')

movesExecuted = open("moves_executed.txt", "w")

moves = []
print "Loading moves..."

for line in f:
    moves.extend((line.rstrip()).split(" "))
print "Moves loaded"

i = 0
for move in moves:
    print "Move number: ", i
    i += 1
    chessboard.printBoard()
    print chessboard.addTextMove(move)
    #print str(getLastMove(chessboard)) + "\n"
    movesExecuted.write(str(chessboard.getLastMove()) + "\n")
    time.sleep(0.1)
    


chessboard.printBoard()
chessboard.printBoardSingleRow()
movesExecuted.close()
